import yaml
import os

COFNIG = 'config.yml'

class Config(object):

    def __init__(self):
        self.__conf = self.__load()

    def __load(self):
        with open(COFNIG) as fd:
            return yaml.load(fd.read(), Loader=yaml.FullLoader)

    def get_monitoring(self):
        '''
        返回监控的文件列表
        :return:
        '''
        return [item.get('path') for item in self.__conf.get('monitoring')]



class Env(object):

    @staticmethod
    def cmd(path):
        '''
        生成cmd
        :param path:
        :return:
        '''
        if os.path.exists(path):
            # return 'tail -f -n 50 {}'.format(path)
            return ["tail", "-n","50","-F", path]

if __name__ == '__main__':
    print(Config().get_monitoring())